package com.snow.utils;

import com.snow.pojo.model.MetaDomain;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

/**
 * @Description:
 * 后台公共函数
 * @author: snow
 * @Date: 2020-01-19
 **/
@Component
public final class AdminCommons {
    /**
     * 判断category和cat的交集
     * @param category
     * @param cat
     * @return
     */
    public static boolean isExitCat(MetaDomain category,String cat){
        String[] split = StringUtils.split(cat, ",");
        if(split != null && split.length > 0){
            for(String str:split){
                if(str.trim().equals(category.getName())){
                    return true;
                }
            }
        }

        return false;
    }
    private static final  String[] COLOR = {"default","primary","success","info","warning","danger","inverse","purple","pink"};

    /**
     * 随机设置颜色
     * @return
     */
    public static String randomColor(){
        int r = Tools.rand(0, COLOR.length - 1);
        return COLOR[r];
    }

}
